<template>
	<view class="page-container">
		<view class="page-header">
			<view class="header-left">
				<text class="page-title">采购申请管理</text>
				<text class="page-subtitle">管理采购申请信息</text>
			</view>
			<view class="header-right">
				<button class="btn btn-primary" @click="handleAdd">
					<text class="icon">+</text> 新增采购
				</button>
			</view>
		</view>

		<view class="filter-section">
			<view class="search-box">
				<input v-model="searchParams.keyword" type="text" placeholder="搜索产品名称..." class="search-input"
					@confirm="handleSearch" />
				<button class="btn-search" @click="handleSearch">搜索</button>
				<button class="btn-reset" @click="handleReset">重置</button>
			</view>

			<view v-if="selectedIds.length > 0" class="batch-actions">
				<text class="batch-count">已选中 {{ selectedIds.length }} 项</text>
				<button class="btn btn-danger btn-small" @click="handleBatchDelete">删除选中</button>
				<button class="btn btn-default btn-small" @click="handleCancelSelect">取消选择</button>
			</view>
		</view>

		<view class="table-wrapper">
			<view v-if="loading" class="loading-state">
				<text class="loading-text">加载中...</text>
			</view>

			<view v-else-if="dataList.length === 0" class="empty-state">
				<text class="empty-icon">📭</text>
				<text class="empty-text">暂无采购申请</text>
				<button class="btn btn-primary" @click="handleAdd">新增采购</button>
			</view>

			<view v-else class="table-container">
				<view class="table-header">
					<view class="table-cell checkbox-cell">
						<checkbox-group @change="handleSelectAll">
							<label><checkbox :checked="isSelectAll" value="all" /></label>
						</checkbox-group>
					</view>
					<view class="table-cell col-type">采购类型</view>
					<view class="table-cell col-product">采购物品</view>
					<view class="table-cell col-quantity">数量</view>
					<view class="table-cell col-applicant">申请人</view>
					<view class="table-cell col-urgency">紧急程度</view>
					<view class="table-cell col-reason">申请原因</view>
					<view class="table-cell col-date">申请日期</view>
					<view class="table-cell col-status">状态</view>
					<view class="table-cell col-actions">操作</view>
				</view>

				<view v-for="item in dataList" :key="item._id" class="table-row"
					:class="{ selected: selectedIds.includes(item._id) }">
					<view class="table-cell checkbox-cell" @click.stop>
						<checkbox-group @change="(e) => handleSelectItem(item._id, e)">
							<label><checkbox :checked="selectedIds.includes(item._id)" :value="item._id" /></label>
						</checkbox-group>
					</view>
					<view class="table-cell col-type clickable" @click="handleView(item._id)">
						<text class="type-badge" :class="'type-' + item.item_type">{{ getItemTypeText(item.item_type) }}</text>
					</view>
					<view class="table-cell col-product clickable" @click="handleView(item._id)">
						<text class="cell-text">{{ getItemName(item.item_id) }}</text>
					</view>
					<view class="table-cell col-quantity clickable" @click="handleView(item._id)">
						<text class="cell-text">{{ item.requested_quantity || 0 }}</text>
					</view>
					<view class="table-cell col-applicant clickable" @click="handleView(item._id)">
						<text class="cell-text">{{ getRequesterName(item.requester_id, item.requester_info) }}</text>
					</view>
					<view class="table-cell col-urgency clickable" @click="handleView(item._id)">
						<text class="urgency-badge" :class="'urgency-' + item.urgency">{{ getUrgencyText(item.urgency) }}</text>
					</view>
					<view class="table-cell col-reason clickable" @click="handleView(item._id)">
						<text class="cell-text reason-text">{{ item.reason || '暂无' }}</text>
					</view>
					<view class="table-cell col-date clickable" @click="handleView(item._id)">
						<text class="cell-text">{{ formatDate(item.create_time) }}</text>
					</view>
					<view class="table-cell col-status clickable" @click="handleView(item._id)">
						<text class="status-badge" :class="'status-' + getStatusClass(item.status)">{{ getStatusText(item.status) }}</text>
					</view>
					<view class="table-cell col-actions" @click.stop>
						<!-- 待审批(status=1): 显示审批按钮（仅admin/manager/director有权限） -->
						<button v-if="item.status === 1 && canApprove" class="action-btn approve-btn" @click="handleApprove(item._id)">审批</button>
						
						<!-- 已批准(status=2): 显示入库按钮（仅purchaser有权限） -->
						<button v-if="item.status === 2 && canStock" class="action-btn stock-btn" @click="handleStock(item._id)">入库</button>
						
						<!-- 已驳回(status=3): 显示查看原因按钮 -->
						<button v-if="item.status === 3" class="action-btn reason-btn" @click="handleShowReason(item)">查看原因</button>
						
						<!-- 已采购(status=4): 显示查看按钮 -->
						<button v-if="item.status === 4" class="action-btn view-btn" @click="handleView(item._id)">查看</button>
						
						<!-- 待审批和已驳回状态可编辑 -->
						<button v-if="item.status === 1 || item.status === 3" class="action-btn edit-btn" @click="handleEdit(item._id)">编辑</button>
						
						<!-- 未完成状态可删除 -->
						<button v-if="item.status !== 4" class="action-btn delete-btn" @click="handleDelete(item._id)">删除</button>
					</view>
				</view>
			</view>
		</view>

		<view v-if="dataList.length > 0" class="pagination-section">
			<view class="pagination-info">
				<text>共 {{ total }} 条数据，第 {{ currentPage }} / {{ totalPages }} 页</text>
				<view class="page-size-selector">
					<text class="selector-label">每页显示</text>
					<picker mode="selector" :range="pageSizeOptions" :value="pageSizeIndex"
						@change="handlePageSizeChange" class="selector-picker">
						<view class="selector-input">{{ pageSize }} 条</view>
					</picker>
				</view>
			</view>
			<view class="pagination-controls">
				<button :disabled="currentPage === 1" class="btn btn-default btn-small"
					@click="handlePreviousPage">上一页</button>
				<button :disabled="currentPage === totalPages" class="btn btn-default btn-small"
					@click="handleNextPage">下一页</button>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'

const dataList = ref([])
const loading = ref(false)
const total = ref(0)
const currentPage = ref(1)
const pageSize = ref(20)
const pageSizeOptions = ['10 条', '20 条', '50 条', '100 条']
const pageSizeValues = [10, 20, 50, 100]
const pageSizeIndex = computed(() => pageSizeValues.indexOf(pageSize.value))
const searchParams = ref({ keyword: '' })
const selectedIds = ref([])
const totalPages = computed(() => Math.ceil(total.value / pageSize.value))
const isSelectAll = computed(() => dataList.value.length > 0 && dataList.value.length === selectedIds.value.length)

// 当前用户角色信息
const currentUserRoles = ref([])

// 审批权限：admin、manager、director
const canApprove = computed(() => {
	return currentUserRoles.value.some(role => ['admin', 'manager', 'director'].includes(role))
})

// 入库权限：admin、manager、purchaser
const canStock = computed(() => {
	return currentUserRoles.value.some(role => ['admin', 'manager', 'purchaser'].includes(role))
})

onMounted(() => {
	loadUserRoles()
	loadData()
})

// 获取当前用户角色
async function loadUserRoles() {
	try {
		const userInfo = uni.getStorageSync('uni-id-pages-userInfo')
		if (userInfo && userInfo.role) {
			currentUserRoles.value = Array.isArray(userInfo.role) ? userInfo.role : [userInfo.role]
		}
	} catch (error) {
		console.error('[采购管理] 获取用户角色失败:', error)
	}
}

async function loadData() {
	loading.value = true
	try {
		const dhPurchaseRequests = uniCloud.importObject('dh-purchase_requests')
		const skip = (currentPage.value - 1) * pageSize.value
		// 支持搜索 product_name 或 item_name
		const query = searchParams.value.keyword ? {
			$or: [
				{ 'item_id.product_name': new RegExp(searchParams.value.keyword) },
				{ 'item_id.item_name': new RegExp(searchParams.value.keyword) }
			]
		} : {}
		const result = await dhPurchaseRequests.listPurchaseRequests(query, skip, pageSize.value)
		
		if (result.code === 200) {
			dataList.value = result.data || []
			total.value = result.count || 0
			selectedIds.value = []
		} else {
			uni.showToast({ title: result.message || '加载失败', icon: 'error' })
		}
	} catch (error) {
		console.error('加载数据失败:', error)
		uni.showToast({ title: '加载数据失败', icon: 'error' })
	} finally {
		loading.value = false
	}
}

function getItemTypeText(itemType) {
	const typeMap = {
		1: '对外销售',
		2: '内部使用'
	}
	return typeMap[itemType] || '未知'
}

function getItemName(itemId) {
	if (!itemId) return '暂无'
	// 尝试获取 item_name (inventory) 或 product_name (product)
	if (typeof itemId === 'object') {
		return itemId.item_name || itemId.product_name || '暂无'
	}
	return '暂无'
}

function getRequesterName(requesterId, requesterInfo) {
	if (requesterInfo) {
		if (requesterInfo.real_name) return requesterInfo.real_name
		if (requesterInfo.nickname) return requesterInfo.nickname
		if (requesterInfo.username) return requesterInfo.username
	}
	return '未知用户'
}

function getUrgencyText(urgency) {
	const urgencyMap = {
		1: '普通',
		2: '加急',
		3: '紧急'
	}
	return urgencyMap[urgency] || '未知'
}

function formatDate(date) {
	if (!date) return '暂无'
	const d = new Date(date)
	return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
}

function getStatusText(status) {
	const statusMap = {
		1: '待审批',
		2: '已批准',
		3: '已驳回',
		4: '已采购'
	}
	return statusMap[status] || '未知'
}

function getStatusClass(status) {
	const classMap = {
		1: 'pending',
		2: 'approved',
		3: 'rejected',
		4: 'purchased'
	}
	return classMap[status] || 'pending'
}

function handleSearch() {
	currentPage.value = 1
	loadData()
}

function handleReset() {
	searchParams.value.keyword = ''
	currentPage.value = 1
	loadData()
}

function handleSelectItem(id, e) {
	const values = e.detail.value
	if (values.includes(id)) {
		if (!selectedIds.value.includes(id)) selectedIds.value.push(id)
	} else {
		const index = selectedIds.value.indexOf(id)
		if (index > -1) selectedIds.value.splice(index, 1)
	}
}

function handleSelectAll(e) {
	const values = e.detail.value
	if (values.includes('all')) {
		selectedIds.value = dataList.value.map(item => item._id)
	} else {
		selectedIds.value = []
	}
}

function handleCancelSelect() {
	selectedIds.value = []
}

function handleAdd() {
	uni.navigateTo({ url: '/pages/business/purchase_requests/add' })
}

function handleView(id) {
	uni.navigateTo({ url: `/pages/business/purchase_requests/detail?id=${id}` })
}

function handleEdit(id) {
	uni.navigateTo({ url: `/pages/business/purchase_requests/edit?id=${id}` })
}

function handleApprove(id) {
	uni.navigateTo({ url: `/pages/business/purchase_requests/approve?id=${id}` })
}

function handleStock(id) {
	uni.navigateTo({ url: `/pages/business/purchase_requests/stock?id=${id}` })
}

function handleShowReason(item) {
	uni.showModal({
		title: '驳回原因',
		content: item.rejection_reason || '暂无驳回原因',
		showCancel: false,
		confirmText: '知道了'
	})
}

async function handleDelete(id) {
	const confirmed = await showConfirm('确认删除', '确定要删除此采购申请吗？')
	if (!confirmed) return
	try {
		const dhPurchaseRequests = uniCloud.importObject('dh-purchase_requests')
		const result = await dhPurchaseRequests.deletePurchaseRequest(id)
		if (result.code === 200) {
			uni.showToast({ title: '删除成功', icon: 'success' })
			loadData()
		} else {
			uni.showToast({ title: result.message || '删除失败', icon: 'error' })
		}
	} catch (error) {
		console.error('删除失败:', error)
		uni.showToast({ title: '删除失败', icon: 'error' })
	}
}

async function handleBatchDelete() {
	if (selectedIds.value.length === 0) {
		uni.showToast({ title: '请选择要删除的项', icon: 'warning' })
		return
	}
	const confirmed = await showConfirm('批量删除', `确定要删除选中的 ${selectedIds.value.length} 项吗？`)
	if (!confirmed) return
	try {
		const dhPurchaseRequests = uniCloud.importObject('dh-purchase_requests')
		const result = await dhPurchaseRequests.batchDeletePurchaseRequests(selectedIds.value)
		if (result.code === 200) {
			uni.showToast({ title: '批量删除成功', icon: 'success' })
			selectedIds.value = []
			loadData()
		} else {
			uni.showToast({ title: result.message || '批量删除失败', icon: 'error' })
		}
	} catch (error) {
		console.error('批量删除失败:', error)
		uni.showToast({ title: '批量删除失败', icon: 'error' })
	}
}

function handlePreviousPage() {
	if (currentPage.value > 1) {
		currentPage.value--
		loadData()
	}
}

function handleNextPage() {
	if (currentPage.value < totalPages.value) {
		currentPage.value++
		loadData()
	}
}

function handlePageSizeChange(e) {
	const index = e.detail.value
	pageSize.value = pageSizeValues[index]
	currentPage.value = 1
	loadData()
}

function showConfirm(title, content) {
	return new Promise((resolve) => {
		uni.showModal({
			title,
			content,
			confirmText: '确定',
			cancelText: '取消',
			success: (res) => {
				resolve(res.confirm)
			}
		})
	})
}
</script>

<style scoped lang="scss">
.page-container {
	padding: 20px;
	background-color: #f5f7fa;
	min-height: 100vh;
}

.page-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 24px;
	background: white;
	padding: 20px;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.header-left {
	display: flex;
	flex-direction: column;
}

.page-title {
	font-size: 20px;
	font-weight: 600;
	color: #1f2937;
	margin-bottom: 4px;
}

.page-subtitle {
	font-size: 12px;
	color: #6b7280;
}

.header-right {
	display: flex;
	gap: 10px;
}

.btn {
	padding: 6px 14px;
	border-radius: 6px;
	border: none;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	transition: all 0.3s ease;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 34px;
	box-sizing: border-box;

	&:disabled {
		opacity: 0.5;
		cursor: not-allowed;
	}

	&.btn-primary {
		background-color: #3b82f6;
		color: white;

		&:active {
			background-color: #2563eb;
		}
	}

	&.btn-default {
		background-color: #e5e7eb;
		color: #374151;

		&:active {
			background-color: #d1d5db;
		}
	}

	&.btn-danger {
		background-color: #ef4444;
		color: white;

		&:active {
			background-color: #dc2626;
		}
	}

	&.btn-small {
		padding: 6px 12px;
		font-size: 12px;
	}
}

.icon {
	font-size: 16px;
}

.filter-section {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-bottom: 20px;
}

.search-box {
	display: flex;
	gap: 8px;
	background: white;
	padding: 12px;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.search-input {
	flex: 1;
	padding: 8px 12px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	font-size: 14px;
	height: 38px;
	box-sizing: border-box;

	&:focus {
		outline: none;
		border-color: #3b82f6;
		box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
	}
}

.btn-search {
	padding: 8px 16px;
	background-color: #3b82f6;
	color: white;
	border: 1px solid #3b82f6;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	height: 38px;
	box-sizing: border-box;
	display: flex;
	align-items: center;

	&:active {
		background-color: #2563eb;
	}
}

.btn-reset {
	padding: 8px 16px;
	background-color: #e5e7eb;
	color: #374151;
	border: 1px solid #e5e7eb;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	height: 38px;
	box-sizing: border-box;
	display: flex;
	align-items: center;

	&:active {
		background-color: #d1d5db;
	}
}

.batch-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	background: white;
	padding: 12px;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.batch-count {
	font-size: 14px;
	color: #6b7280;
	font-weight: 500;
}

.table-wrapper {
	background: white;
	border-radius: 8px;
	overflow-x: auto;
	overflow-y: visible;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	margin-bottom: 20px;
}

.loading-state,
.empty-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 60px 20px;
}

.loading-text {
	font-size: 14px;
	color: #6b7280;
}

.empty-icon {
	font-size: 48px;
	margin-bottom: 12px;
}

.empty-text {
	font-size: 14px;
	color: #6b7280;
	margin-bottom: 16px;
}

.table-container {
	min-width: 1360px;
	width: max-content;
}

.table-header {
	display: grid;
	grid-template-columns: 40px 100px 150px 80px 120px 90px 1fr 110px 100px 180px;
	gap: 12px;
	padding: 12px 16px;
	background-color: #f9fafb;
	border-bottom: 1px solid #e5e7eb;
	font-size: 12px;
	font-weight: 600;
	color: #6b7280;
	text-transform: uppercase;
	letter-spacing: 0.5px;

	.table-cell {
		justify-content: center;
	}

	.col-actions {
		justify-content: flex-start;
	}
}

.table-row {
	display: grid;
	grid-template-columns: 40px 100px 150px 80px 120px 90px 1fr 110px 100px 180px;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid #e5e7eb;
	align-items: center;
	transition: background-color 0.2s ease, border-left 0.2s ease;

	&:hover {
		background-color: #f9fafb;
	}

	&:last-child {
		border-bottom: none;
	}

	&.selected {
		background-color: #eff6ff;
		border-left: 3px solid #3b82f6;
		padding-left: 13px;
	}

	.table-cell {
		justify-content: center;
	}

	.col-actions {
		justify-content: flex-start;
	}
}

.table-cell {
	display: flex;
	align-items: center;
}

.checkbox-cell {
	justify-content: center;

	checkbox-group {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	label {
		display: flex;
		align-items: center;
		justify-content: center;
		cursor: pointer;
	}

	checkbox {
		transform: scale(1.1);
	}
}

.cell-text {
	font-size: 14px;
	color: #1f2937;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;

	&.reason-text {
		max-width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
}

.type-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;

	&.type-1 {
		background-color: #dbeafe;
		color: #1e40af;
	}

	&.type-2 {
		background-color: #d1fae5;
		color: #065f46;
	}
}

.urgency-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;

	&.urgency-1 {
		background-color: #e0e7ff;
		color: #3730a3;
	}

	&.urgency-2 {
		background-color: #fef3c7;
		color: #92400e;
	}

	&.urgency-3 {
		background-color: #fee2e2;
		color: #991b1b;
	}
}

.status-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;

	&.status-pending {
		background-color: #fef3c7;
		color: #92400e;
	}

	&.status-approved {
		background-color: #d1fae5;
		color: #065f46;
	}

	&.status-rejected {
		background-color: #fee2e2;
		color: #7f1d1d;
	}

	&.status-purchased {
		background-color: #dbeafe;
		color: #1e40af;
	}
}

.col-actions {
	display: flex;
	gap: 8px;
	justify-content: flex-start;
	align-items: center;
	padding-left: 8px;
}

.clickable {
	cursor: pointer;
	transition: background-color 0.2s ease;

	&:hover {
		background-color: #f9fafb;
	}
}

.action-btn {
	padding: 4px 12px;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 12px;
	font-weight: 500;
	transition: all 0.3s ease;
	white-space: nowrap;
	height: 26px;
	min-width: 50px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;

	&.approve-btn {
		background-color: #d1fae5;
		color: #065f46;

		&:hover {
			background-color: #a7f3d0;
		}

		&:active {
			background-color: #6ee7b7;
		}
	}

	&.stock-btn {
		background-color: #dbeafe;
		color: #1e40af;

		&:hover {
			background-color: #bfdbfe;
		}

		&:active {
			background-color: #93c5fd;
		}
	}

	&.reason-btn {
		background-color: #fce7f3;
		color: #9f1239;

		&:hover {
			background-color: #fbcfe8;
		}

		&:active {
			background-color: #f9a8d4;
		}
	}

	&.view-btn {
		background-color: #e0e7ff;
		color: #3730a3;

		&:hover {
			background-color: #c7d2fe;
		}

		&:active {
			background-color: #a5b4fc;
		}
	}

	&.edit-btn {
		background-color: #fef3c7;
		color: #92400e;

		&:hover {
			background-color: #fde68a;
		}

		&:active {
			background-color: #fcd34d;
		}
	}

	&.delete-btn {
		background-color: #fee2e2;
		color: #991b1b;

		&:hover {
			background-color: #fecaca;
		}

		&:active {
			background-color: #fca5a5;
		}
	}
}

.pagination-section {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: white;
	padding: 16px;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.pagination-info {
	display: flex;
	align-items: center;
	gap: 16px;
	font-size: 12px;
	color: #6b7280;
}

.page-size-selector {
	display: flex;
	align-items: center;
	gap: 8px;
}

.selector-label {
	font-size: 12px;
	color: #6b7280;
}

.selector-picker {
	flex-shrink: 0;
}

.selector-input {
	padding: 4px 8px;
	border: 1px solid #d1d5db;
	border-radius: 4px;
	font-size: 12px;
	color: #374151;
	background-color: white;
	cursor: pointer;
	min-width: 70px;
	text-align: center;
}

.pagination-controls {
	display: flex;
	gap: 8px;
}

@media (max-width: 768px) {
	.page-container {
		padding: 12px;
	}

	.page-header {
		flex-direction: row;
		align-items: center;
		gap: 8px;
		padding: 12px;
	}

	.header-left {
		flex: 1;
		min-width: 0;
	}

	.header-right {
		flex-shrink: 0;
	}

	.page-title {
		font-size: 16px;
	}

	.page-subtitle {
		font-size: 11px;
		line-height: 1.4;
	}

	.btn {
		padding: 6px 12px;
		font-size: 13px;
		height: auto;
	}

	.search-box {
		flex-wrap: wrap;
	}

	.search-input {
		width: 100%;
		flex: 1 1 100%;
		margin-bottom: 8px;
	}

	.btn-search,
	.btn-reset {
		flex: 1;
		justify-content: center;
	}

	.batch-actions {
		flex-wrap: wrap;
	}

	.table-wrapper {
		overflow-x: auto;
	}

	.table-container {
		min-width: 1360px;
	}

	.pagination-section {
		flex-direction: column;
		gap: 12px;
		align-items: flex-start;
	}

	.pagination-info {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
		width: 100%;
	}

	.page-size-selector {
		width: 100%;
		justify-content: space-between;
	}

	.selector-picker {
		flex: 0 0 auto;
	}

	.selector-input {
		min-width: 80px;
	}

	.pagination-controls {
		width: 100%;
		justify-content: space-between;
	}

	.btn.btn-small {
		flex: 1;
	}
}
</style>
